//
//  UIUtil.m
//  Yueshi
//
//  Created by Northwan on 15/7/15.
//  Copyright (c) 2015年 悦食中国. All rights reserved.
//

#import "UIUtil.h"

@implementation UIUtil
/**
 * 处理tabview的线条样式
 */
+(void)setSeparatorInsetWithTableView:(UITableView *)tableView insets:(UIEdgeInsets)insets{
    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [tableView setSeparatorInset:insets];
    }
    if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [tableView setLayoutMargins:insets];
    }
}

+(void)setSeparatorInsetWithTableViewCell:(UITableViewCell *)cell insets:(UIEdgeInsets)insets{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:insets];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:insets];
    }
}

+ (void)refreshComplete:(UITableView *)tableView{
    [tableView.header endRefreshing];
    [tableView.footer endRefreshing];
}

+(void)dealPlaceHolderColor:(UITextField *)tf color:(UIColor *)color{
    [tf setValue:color forKeyPath:@"_placeholderLabel.textColor"];
    [tf setValue:[UIFont boldSystemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];
}

+(void)dealPlaceHolderSize:(UITextField *)tf size:(CGFloat)size{
    [tf setValue:[UIFont systemFontOfSize:size] forKeyPath:@"_placeholderLabel.font"];
}

+(UILabel *)getPageTipLabelWithTipText:(NSString *)tipText{
    CGSize nullTipsSize = [tipText sizeWithFont:SYS_FONT(17)];
    UILabel *nullPageLabel= [[UILabel alloc]initWithFrame:CGRectMake(0,(SCREENH-NavWithStatusBarH-nullTipsSize.height)/2, SCREENW, 17)];
    [nullPageLabel setText:tipText];
    [nullPageLabel setFont:SYS_FONT(17)];
    [nullPageLabel setTextColor:HEXColor(@"#333333")];
    [nullPageLabel setTextAlignment:NSTextAlignmentCenter];
    return nullPageLabel;
}

/**
 *添加删除线
 */
+(void)addMiddleLineWithLabel:(UILabel *)label text:(NSString *)text{
    NSUInteger length = [text length];
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:text];
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)];
    [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor colorWithHexString:@"#9e9e9e"] range:NSMakeRange(0, length)];
    [label setAttributedText:attri];
}

@end
